package toubiao.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import toubiao.service.init.InitServiceI;

@Controller
@RequestMapping("/init")
public class InitController implements ApplicationListener<ContextRefreshedEvent>{
	
	@Autowired
	private InitServiceI initService;
	
	@RequestMapping
	public void initDatabaseOfResourceRoleUser(){
		initService.initAll();
	}

	@Override
	public void onApplicationEvent(ContextRefreshedEvent event) {
		/*System.out.println("in onApplicationEvent");
		//initDatabaseOfResourceRoleUser();
		// TODO Auto-generated method stub
		if(event.getApplicationContext().getParent() == null){//root application context 没有parent，他就是老大.  
	         //需要执行的逻辑代码，当spring容器初始化完成后就会执行该方法。  
			System.out.println("in onApplicationEvent");
			initDatabaseOfResourceRoleUser();
	    }  */
	}
}
